import pandas as pd
import plotly.express as px
circuits_data = pd.read_csv('Data\circuits.csv')
circuits_data
| circuitId | circuitRef | name | location | country | lat | lng | alt | url | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | albert_park | Albert Park Grand Prix Circuit | Melbourne | Australia | -37.84970 | 144.96800 | 10 | http://en.wikipedia.org/wiki/Melbourne_Grand_P... |
| 1 | 2 | sepang | Sepang International Circuit | Kuala Lumpur | Malaysia | 2.76083 | 101.73800 | \N | http://en.wikipedia.org/wiki/Sepang_Internatio... |
| 2 | 3 | bahrain | Bahrain International Circuit | Sakhir | Bahrain | 26.03250 | 50.51060 | \N | http://en.wikipedia.org/wiki/Bahrain_Internati... |
| 3 | 4 | catalunya | Circuit de Barcelona-Catalunya | Montmeló | Spain | 41.57000 | 2.26111 | \N | http://en.wikipedia.org/wiki/Circuit_de_Barcel... |
| 4 | 5 | istanbul | Istanbul Park | Istanbul | Turkey | 40.95170 | 29.40500 | \N | http://en.wikipedia.org/wiki/Istanbul_Park |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 71 | 72 | port_imperial | Port Imperial Street Circuit | New Jersey | USA | 40.77690 | -74.01110 | \N | http://en.wikipedia.org/wiki/Port_Imperial_Str... |
| 72 | 73 | BAK | Baku City Circuit | Baku | Azerbaijan | 40.37250 | 49.85330 | \N | http://en.wikipedia.org/wiki/Baku_City_Circuit |
| 73 | 74 | hanoi | Hanoi Street Circuit | Hanoi | Vietnam | 21.01660 | 105.76600 | \N | http://en.wikipedia.org/wiki/Hanoi_Street_Circuit |
| 74 | 75 | portimao | Autódromo Internacional do Algarve | Portimão | Portugal | 37.22700 | -8.62670 | \N | http://en.wikipedia.org/wiki/Algarve_Internati... |
| 75 | 76 | mugello | Autodromo Internazionale del Mugello | Mugello | Italy | 43.99750 | 11.37190 | \N | http://en.wikipedia.org/wiki/Mugello_Circuit |
76 rows × 9 columns
races_data = pd.read_csv(r'Data\races.csv')
races_data
| raceId | year | round | circuitId | name | date | time | url | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 2009 | 1 | 1 | Australian Grand Prix | 2009-03-29 | 06:00:00 | http://en.wikipedia.org/wiki/2009_Australian_G... |
| 1 | 2 | 2009 | 2 | 2 | Malaysian Grand Prix | 2009-04-05 | 09:00:00 | http://en.wikipedia.org/wiki/2009_Malaysian_Gr... |
| 2 | 3 | 2009 | 3 | 17 | Chinese Grand Prix | 2009-04-19 | 07:00:00 | http://en.wikipedia.org/wiki/2009_Chinese_Gran... |
| 3 | 4 | 2009 | 4 | 3 | Bahrain Grand Prix | 2009-04-26 | 12:00:00 | http://en.wikipedia.org/wiki/2009_Bahrain_Gran... |
| 4 | 5 | 2009 | 5 | 4 | Spanish Grand Prix | 2009-05-10 | 12:00:00 | http://en.wikipedia.org/wiki/2009_Spanish_Gran... |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 1030 | 1043 | 2020 | 13 | 21 | Emilia Romagna Grand Prix | 2020-11-01 | 12:10:00 | https://en.wikipedia.org/wiki/2020_Emilia_Roma... |
| 1031 | 1044 | 2020 | 14 | 5 | Turkish Grand Prix | 2020-11-15 | 10:10:00 | https://en.wikipedia.org/wiki/2020_Turkish_Gra... |
| 1032 | 1045 | 2020 | 15 | 3 | Bahrain Grand Prix | 2020-11-29 | 14:10:00 | https://en.wikipedia.org/wiki/2020_Bahrain_Gra... |
| 1033 | 1046 | 2020 | 16 | 3 | Sakhir Grand Prix | 2020-12-06 | 17:10:00 | https://en.wikipedia.org/wiki/2020_Sakhir_Gran... |
| 1034 | 1047 | 2020 | 17 | 24 | Abu Dhabi Grand Prix | 2020-12-13 | 13:10:00 | https://en.wikipedia.org/wiki/2020_Abu_Dhabi_G... |
1035 rows × 8 columns
circuits_data['count'] = [(races_data['circuitId']==i).sum() for i in circuits_data['circuitId']]
circuits_data
| circuitId | circuitRef | name | location | country | lat | lng | alt | url | count | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | albert_park | Albert Park Grand Prix Circuit | Melbourne | Australia | -37.84970 | 144.96800 | 10 | http://en.wikipedia.org/wiki/Melbourne_Grand_P... | 24 |
| 1 | 2 | sepang | Sepang International Circuit | Kuala Lumpur | Malaysia | 2.76083 | 101.73800 | \N | http://en.wikipedia.org/wiki/Sepang_Internatio... | 19 |
| 2 | 3 | bahrain | Bahrain International Circuit | Sakhir | Bahrain | 26.03250 | 50.51060 | \N | http://en.wikipedia.org/wiki/Bahrain_Internati... | 17 |
| 3 | 4 | catalunya | Circuit de Barcelona-Catalunya | Montmeló | Spain | 41.57000 | 2.26111 | \N | http://en.wikipedia.org/wiki/Circuit_de_Barcel... | 30 |
| 4 | 5 | istanbul | Istanbul Park | Istanbul | Turkey | 40.95170 | 29.40500 | \N | http://en.wikipedia.org/wiki/Istanbul_Park | 8 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 71 | 72 | port_imperial | Port Imperial Street Circuit | New Jersey | USA | 40.77690 | -74.01110 | \N | http://en.wikipedia.org/wiki/Port_Imperial_Str... | 0 |
| 72 | 73 | BAK | Baku City Circuit | Baku | Azerbaijan | 40.37250 | 49.85330 | \N | http://en.wikipedia.org/wiki/Baku_City_Circuit | 4 |
| 73 | 74 | hanoi | Hanoi Street Circuit | Hanoi | Vietnam | 21.01660 | 105.76600 | \N | http://en.wikipedia.org/wiki/Hanoi_Street_Circuit | 0 |
| 74 | 75 | portimao | Autódromo Internacional do Algarve | Portimão | Portugal | 37.22700 | -8.62670 | \N | http://en.wikipedia.org/wiki/Algarve_Internati... | 1 |
| 75 | 76 | mugello | Autodromo Internazionale del Mugello | Mugello | Italy | 43.99750 | 11.37190 | \N | http://en.wikipedia.org/wiki/Mugello_Circuit | 1 |
76 rows × 10 columns
fig = px.scatter_geo(data_frame=circuits_data,
lat='lat',
lon='lng',
hover_name="name",
hover_data=['location','country'],
color='count',
opacity=0.75)
fig.show()
num_races = pd.DataFrame(races_data['year'].value_counts().sort_index())
num_races = num_races.reset_index()
num_races.columns = ['Year','Races']
num_races
| Year | Races | |
|---|---|---|
| 0 | 1950 | 7 |
| 1 | 1951 | 8 |
| 2 | 1952 | 8 |
| 3 | 1953 | 9 |
| 4 | 1954 | 9 |
| ... | ... | ... |
| 66 | 2016 | 21 |
| 67 | 2017 | 20 |
| 68 | 2018 | 21 |
| 69 | 2019 | 21 |
| 70 | 2020 | 17 |
71 rows × 2 columns
px.line(num_races,x='Year',y='Races')